package com.example.yunxinagyue

import android.graphics.drawable.Drawable
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.viewpager.widget.PagerAdapter

class LopperAdapter(
    private val lopper:List<Drawable>
): PagerAdapter() {
    override fun getCount(): Int {
        return lopper.size
    }

    override fun isViewFromObject(view: View, `object`: Any): Boolean {
              return view==`object`
    }

    override fun instantiateItem(container: ViewGroup, position: Int): Any {
        val img= ImageView(container.context)
        img.setImageDrawable(lopper[position])
        container.addView(img)
        return img
    }

    override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
        super.destroyItem(container, position, `object`)
        container.removeView(`object` as View)
    }
}